<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            margin-top: 10px;
            position: relative;
        }
        .box1 {
            background-color: pink;
        }
    </style>
</head>
<body>
    <button>执行动画</button>
    <div class="box1">1</div>
    <div class="box1">2</div>
    <div class="box1">3</div>
    <div class="box1">4</div>
    <div class="box1">5</div>
    <div class="box1">6</div>
    <div class="box1">7</div>
    <div class="box1">8</div>
    <div class="box1">9</div>
    <script src="./js/jquery-1.12.3.js"></script>
    <script>
        // 点击按钮执行动画，更改元素位置
        var btn = $("button");
        
        // 一、延迟
        // btn.click(function () {
        //     // 点击后盒子后移动到800位置
        //     // $(".box1").animate({left:800}, 2000);

        //     // 点击后盒子1s后移动到800位置
        //     console.log("点击了");
        //     $(".box1").delay(1000).animate({left:800}, 2000);

        // });
        
        // 这些盒子每隔1s执行一个
        btn.click(function(){
            $(".box1").each(function (index, item) {
                $(item).delay(index*1000).animate({left:800}, 2000);
            })
        })
    </script>
</body>
</html>